package com.jhcee.jhgk.inform.controller;

import com.jhcee.jhgk.inform.service.WechatConfigInfoService;
import com.jhgk.jhcee.common.resultful.BasisResultful;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author: xiezhongping
 * @description:
 * @date: 2021/8/29 15:16.
 */
@RestController
@RequestMapping("/wechat")
public class WechatConfigInfoController {

    @Resource(name = "WechatConfigInfoServiceImpl")
    private WechatConfigInfoService wechatConfigInfoService;

    @GetMapping("/updateToken")
    public BasisResultful updateToken(@RequestParam("appid") @NotBlank(message = "id不能为空") String appid) {
        return wechatConfigInfoService.updateToken(appid);
    }

    @GetMapping("/getToken")
    public BasisResultful getToken(@RequestParam("appid") @NotBlank(message = "id不能为空") String appid) {
        return wechatConfigInfoService.getToken(appid);
    }

    @GetMapping("/sendAllTextMessage")
    public BasisResultful sendAllTextMessage(@RequestParam("agentId") @NotNull(message = "agentId不能为空") int agentId,@RequestParam("text") @NotBlank(message = "发送内容不能为空") String text) {
        return wechatConfigInfoService.sendAllTextMessage(agentId,text);
    }
}
